﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="campaign_manage.aspx.cs"
    Inherits="TCDC_System.Content.TransectionData.campaign_manage" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register TagPrefix="uc" Src="~/UserControl/CampaignManageAdd.ascx" TagName="CampaignManageAdd" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var exportData = function (GridData, GridPanel) {
            GridData.setValue(Ext.encode(GridPanel.getRowsValues({ selectedOnly: false })));
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="mainResource" runat="server" CleanResourceUrl="false" />
    <ext:Hidden ID="GridData" runat="server" />
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:GridPanel ID="GridPanelCampaign" runat="server" Region="Center" DDGroup="gridDDGroup"
                EnableDragDrop="false" StripeRows="true" Title="Campaign Manage" Icon="Vcard"
                Frame="true">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button ID="btAdd" runat="server" Text="Add" Icon="Add" OnDirectClick="AddCampaign" />
                            <ext:ToolbarSeparator />
                            <ext:Button ID="btDelete" runat="server" Text="Delete" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="DeleteCampaign">
                                        <EventMask ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator />
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                            <ext:Button ID="btExcel" runat="server" AutoPostBack="true" OnClick="ExportExcelCampaign"
                                Text="To Excel" Icon="PageExcel">
                                <Listeners>
                                    <Click Handler="exportData(#{GridData},#{GridPanelCampaign});" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store runat="server" ID="StoreCampaign" OnRefreshData="StoreCampaign_Refresh">
                        <Reader>
                            <ext:JsonReader IDProperty="campaign_id">
                                <Fields>
                                    <%--<ext:RecordField Name="campaign_id" />--%>
                                    <ext:RecordField Name="product_id" />
                                    <ext:RecordField Name="campaign_group_id" />
                                    <ext:RecordField Name="campaign_name" />
                                    <ext:RecordField Name="member_type_name_en" />
                                    <ext:RecordField Name="begin_date" Type="Date" />
                                    <ext:RecordField Name="end_date" Type="Date" />
                                    <ext:RecordField Name="member_type_id" />
                                    <%--                  <ext:RecordField Name="add_year" />
                                    <ext:RecordField Name="add_month" />--%>
                                    <ext:RecordField Name="price" />
                                    <%--            <ext:RecordField Name="promotion_code" />
                                    <ext:RecordField Name="promotion_public" />
                                    <ext:RecordField Name="site_id" />--%>
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Header="ID" DataIndex="campaign_id" Width="100" />
                        <ext:Column Header="Campaign Name" DataIndex="campaign_name" Width="300" />
                        <ext:Column Header="Member Type" DataIndex="member_type_name_en" Width="200" />
                        <ext:DateColumn Header="วันเริ่มต้น" Width="100" DataIndex="begin_date" Format="yyyy-MM-dd"
                            Align="Center" />
                        <ext:DateColumn Header="วันสิ้นสุด" Width="100" DataIndex="end_date" Format="yyyy-MM-dd"
                            Align="Center" />
                        <ext:Column Header="Price" DataIndex="price" Width="100" Align="Right" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="19" DisplayInfo="true"
                        EmptyMsg="No Request to display" />
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <uc:CampaignManageAdd ID="CampaignManageAdd" runat="server" />
    </form>
</body>
</html>
